import { ILoadMapTypeAll } from '@/common';
import { ManageCommonAPI } from '@/pages/type';
import { getLevelZeroJson, getSelectDataCommon, getSelectDataMapList, getTenantID } from '@/utils';

const getSearchList = (loadMdicMapList: Record<string, any>, queryTypeObj: Record<string, any>): ManageCommonAPI.ISearchList => {
  /**资产分类数据字典*/
  // const materialTypeMapList = loadMdicMapList?.loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`];
  const materialTypeMapList = getSelectDataMapList(loadMdicMapList?.loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`], 'name', 'id', true);

  /**资产状态数据字典*/
  const assetState = getSelectDataCommon(loadMdicMapList?.loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.ASSET_STATUS}`], 'name', 'id');

  /** 产权列表 */
  const ownershipList = getSelectDataCommon(loadMdicMapList?.loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.ASSET_EQUITY}`], 'name', 'id');

  const searchColumns: any = [
    {
      name: 'assetName',
      placeholder: '资产名称',
      label: '资产名称',
      componentType: 'Input',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'assetClass',
      placeholder: '资产分类',
      label: '资产分类',
      componentType: 'TreeSelect',
      dataSource: materialTypeMapList,
      allowClear: true,
      showSearch: true,
      treeNodeFilterProp: 'name',
      md: 4,
      sm: 24,
      whetherSenior: false,
      treeID: 'id',
      treeName: 'name',
      treeChildren: 'children',
    },
    // {
    //   name: 'assetClassCode',
    //   placeholder: '资产分类编码',
    //   label: '资产分类编码',
    //   componentType: 'Input',
    //   allowClear: true,
    //   md: 4,
    //   sm: 24,
    //   whetherSenior: false,
    // },
    {
      name: 'createTime',
      placeholder: '创建',
      label: '创建',
      componentType: 'RangePicker',
      allowClear: true,
      md: 12,
      sm: 24,
      whetherSenior: false,
    },
    /**===============================高级搜素================================*/
    {
      name: 'assetState',
      placeholder: '资产状态',
      label: '资产状态',
      componentType: 'Select',
      dataSource: assetState,
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: true,
    },
    {
      name: 'ownership',
      placeholder: '产权',
      label: '产权',
      componentType: 'Select',
      dataSource: ownershipList,
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: true,
    },
    {
      name: 'assetValue',
      placeholder: '参考单价',
      label: '参考单价',
      componentType: 'NumberRange',
      allowClear: true,
      md: 12,
      sm: 24,
      whetherSenior: true,
    },
    {
      name: 'userDepartmentFormName',
      placeholder: '保管',
      label: '保管',
      componentType: 'DeptAndUser',
      dataSource: getLevelZeroJson() ?? [],
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: true,
      formOrgType: {
        COMP: 'userCompanyID',
        DEPT: 'userDepartmentID',
        POS: 'userPositionID',
        USER: 'userID',
      },
    },
  ];

  return searchColumns;
};

export { getSearchList };
